import { query } from '~/services/user';

export default {

  namespace: 'user',

  state: {
    count: 0,
  },

  subscriptions: {
    setup({ dispatch, history }) {
    },
  },

  effects: {
    * click({ payload }, { call, put, select }) {
      const { count } = yield select(({ user }) => user);
      const { add } = yield call(query, {});
      yield put({
        type: 'fetch',
        payload: {
          count: count + add,
        },
      });
    },
  },

  reducers: {
    fetch(state, action) {
      return { ...state, ...action.payload };
    },
  },

};
